package com.boy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.boy.entity.Log;
import com.boy.mapper.LogMapper;
import com.boy.service.LogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boy.tool.domain.Pos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author whd
 * @since 2024-05-23
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements LogService {

    @Autowired
    private LogMapper logMapper;

    @Override
    public void create(Log log) {
        logMapper.insert(log);
    }

    @Override
    public IPage<Log> findPage(Pos pos, String name) {
        Page<Log> page = new Page<>(pos.getCurPage(), pos.getPageSize());
        QueryWrapper<Log> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(name != null, "account_name", name).orderByDesc("created");
        IPage<Log> logIPage = baseMapper.selectPage(page, queryWrapper);
        return logIPage;
    }
}
